<?php
	include 'inc/conn.php';

	header ("Content-type:application/vnd.ms-excel");
	header ("Content-Disposition:filename=ENG-B131.xls");
	echo "<table border='1'>";
	echo "<tr><td align='center' colspan='11'><font size='5'>库存管控表</font></td></tr>";
	echo "<tr style='font-size: 16px;height: 30px;'>";
	echo " <td align='center' bgcolor='#538dd5'><font color='ffffff'>编号</font></td>"; 
	echo " <td align='center' bgcolor='#538dd5'><font color='ffffff'>类型</font></td>"; 
	echo " <td align='center' bgcolor='#538dd5'><font color='ffffff'>料号</font></td>";
	echo " <td align='center' bgcolor='#538dd5'><font color='ffffff'>描述</font></td>";
	echo " <td align='center' bgcolor='#538dd5'><font color='ffffff'>数量</font></td>";
	echo " <td align='center' bgcolor='#538dd5'><font color='ffffff'>部门</font></td>";
	echo " <td align='center' bgcolor='#538dd5'><font color='ffffff'>保管人</font></td>"; 
	echo " <td align='center' bgcolor='#538dd5'><font color='ffffff'>状态</font></td>"; 
	echo " <td align='center' bgcolor='#538dd5'><font color='ffffff'>登记日期</font></td>";
	echo " <td align='center' bgcolor='#538dd5'><font color='ffffff'>更新日期</font></td>";
	echo " <td align='center' bgcolor='#538dd5'><font color='ffffff'>备注</font></td>";
	echo "</tr>";

	$db = new mysql();
	$sql = "select * from eng_repo order by KP_PN ASC";
	$db->query($sql);
	$num = $db->db_num_rows();
	if ($num == 0)
		echo "No data was found!";

	for($i=0; $i<$num; $i++){
		$row = $db->fetch_assoc();
		$j=$i+1;
		echo "<tr><td align='center'>$j</td><td align='center'>".
			htmlspecialchars_decode($row['KP_TYPE'])."</td><td align='left'>".
			htmlspecialchars_decode($row['KP_PN'])."</td><td align='left'>".
			htmlspecialchars_decode($row['KP_DESC'])."</td><td align='center'>".
			htmlspecialchars_decode($row['KP_NUM'])."</td><td align='center'>".
			htmlspecialchars_decode($row['DEPT'])."</td><td align='left'>".
			htmlspecialchars_decode($row['KP_OWNER'])."</td><td align='center'>".
			htmlspecialchars_decode($row['STATUS'])."</td><td align='center'>".
			htmlspecialchars_decode($row['KP_CHECKIN_DATE'])."</td><td align='center'>".
			htmlspecialchars_decode($row['KP_CHECKOUT_DATE'])."</td><td align='center'>".
			htmlspecialchars_decode($row['REMARK'])."</td></tr>";
	}
	echo "</table>";
	$db->close();
?>